var app = angular.module('app', [ 'ngRoute', 'appControllers' ]);

app.config([ '$routeProvider', '$locationProvider', '$httpProvider',
    function ($routeProvider, $locationProvider, $httpProvider) {
        $routeProvider.when('/page1', {
            templateUrl: 'partials/page1.html',
            controller: 'page1'
        }).when('/page2', {
                templateUrl: 'partials/page2.html',
                controller: 'page2'
            }).when('/page2/:phoneId', {
                templateUrl: 'partials/page2.html',
                controller: 'page2'
            }).otherwise({
                // redirectTo : '/page1'
                templateUrl: 'partials/404.html'
            });

        $locationProvider.html5Mode(true).hashPrefix('!');

        $httpProvider.interceptors.push(function () {
            return {
                'request': function (config) {
                    console.log('request');
                    return config;
                },
                'response': function (rejection) {
                    console.log('error');
                    return rejection;
                }
            };
        });
    } ]);
